Added a VM.domid field.
authorEwan Mellor <ewan@xensource.com>
Sun, 25 Feb 2007 22:31:43 +0000 (22:31 +0000)
committerEwan Mellor <ewan@xensource.com>
Sun, 25 Feb 2007 22:31:43 +0000 (22:31 +0000)
Signed-off-by: Ewan Mellor <ewan@xensource.com>
docs/xen-api/xenapi-datamodel.tex
tools/libxen/include/xen_vm.h
tools/libxen/src/xen_vm.c
tools/python/xen/xend/XendAPI.py

index 53a25d56880951eec3c332674b8714e21d98e71e..09d9dc6098c1464a1cf7a883ee9358e36755f959 100644 (file)
@@ -1100,6 +1100,7 @@ $\mathit{RW}$ &  {\tt platform/enable\_audio} & bool & emulate audio \\
 $\mathit{RO}_\mathit{ins}$ &  {\tt PCI\_bus} & string & PCI bus path for pass-through devices \\
 $\mathit{RO}_\mathit{run}$ &  {\tt tools\_version} & (string $\rightarrow$ string) Map & versions of installed paravirtualised drivers \\
 $\mathit{RW}$ &  {\tt other\_config} & (string $\rightarrow$ string) Map & additional configuration \\
+$\mathit{RO}_\mathit{run}$ &  {\tt domid} & int & domain ID (if available, -1 otherwise) \\
 $\mathit{RO}_\mathit{run}$ &  {\tt is\_control\_domain} & bool & true if this is a control domain (domain 0 or a driver domain) \\
 $\mathit{RO}_\mathit{run}$ &  {\tt metrics} & VM\_metrics ref & metrics associated with this VM. \\
 \hline
@@ -3966,6 +3967,38 @@ void
 
 
 
+\vspace{0.3cm}
+\vspace{0.3cm}
+\vspace{0.3cm}
+\subsubsection{RPC name:~get\_domid}
+
+{\bf Overview:} 
+Get the domid field of the given VM.
+
+ \noindent {\bf Signature:} 
+\begin{verbatim} int get_domid (session_id s, VM ref self)\end{verbatim}
+
+
+\noindent{\bf Arguments:}
+
+\vspace{0.3cm}
+\begin{tabular}{|c|c|p{7cm}|}
+ \hline
+{\bf type} & {\bf name} & {\bf description} \\ \hline
+{\tt VM ref } & self & reference to the object \\ \hline 
+
+\end{tabular}
+
+\vspace{0.3cm}
+
+ \noindent {\bf Return Type:} 
+{\tt 
+int
+}
+
+
+value of the field
 \vspace{0.3cm}
 \vspace{0.3cm}
 \vspace{0.3cm}
index 15abbb11c7b78f90373ca39bfc431b1e59dfdc63..228a3dcb07623c7387895b7dc4422f11ee953f36 100644 (file)
@@ -146,6 +146,7 @@ typedef struct xen_vm_record
     char *pci_bus;
     xen_string_string_map *tools_version;
     xen_string_string_map *other_config;
+    int64_t domid;
     bool is_control_domain;
     struct xen_vm_metrics_record_opt *metrics;
 } xen_vm_record;
@@ -546,6 +547,13 @@ extern bool
 xen_vm_get_other_config(xen_session *session, xen_string_string_map **result, xen_vm vm);
 
 
+/**
+ * Get the domid field of the given VM.
+ */
+extern bool
+xen_vm_get_domid(xen_session *session, int64_t *result, xen_vm vm);
+
+
 /**
  * Get the is_control_domain field of the given VM.
  */
index c712b715614ca5a1118a47d2eecc4c69ff373ea4..1d93e6a84089f9927af18280fa9af82896b3ba58 100644 (file)
@@ -168,6 +168,9 @@ static const struct_member xen_vm_record_struct_members[] =
         { .key = "other_config",
           .type = &abstract_type_string_string_map,
           .offset = offsetof(xen_vm_record, other_config) },
+        { .key = "domid",
+          .type = &abstract_type_int,
+          .offset = offsetof(xen_vm_record, domid) },
         { .key = "is_control_domain",
           .type = &abstract_type_bool,
           .offset = offsetof(xen_vm_record, is_control_domain) },
@@ -952,6 +955,22 @@ xen_vm_get_other_config(xen_session *session, xen_string_string_map **result, xe
 }
 
 
+bool
+xen_vm_get_domid(xen_session *session, int64_t *result, xen_vm vm)
+{
+    abstract_value param_values[] =
+        {
+            { .type = &abstract_type_string,
+              .u.string_val = vm }
+        };
+
+    abstract_type result_type = abstract_type_int;
+
+    XEN_CALL_("VM.get_domid");
+    return session->ok;
+}
+
+
 bool
 xen_vm_get_is_control_domain(xen_session *session, bool *result, xen_vm vm)
 {
index f5281127382c71c90a683ba63e17fc61c7504568..abb1118dcdb6fee496ab2c11586fbb8e08fd35fe 100644 (file)
@@ -1000,6 +1000,7 @@ class XendAPI(object):
                   'VTPMs',
                   'PCI_bus',
                   'tools_version',
+                  'domid',
                   'is_control_domain',
                   ]
                   
@@ -1240,6 +1241,10 @@ class XendAPI(object):
     def VM_get_other_config(self, session, vm_ref):
         return self.VM_get('other_config', session, vm_ref)        
 
+    def VM_get_domid(self, _, ref):
+        domid = XendDomain.instance().get_vm_by_uuid(ref).getDomid()
+        return xen_api_success(domid is None and -1 or domid)
+
     def VM_get_is_control_domain(self, session, vm_ref):
         xd = XendDomain.instance()
         return xen_api_success(
@@ -1396,7 +1401,9 @@ class XendAPI(object):
         xeninfo = xendom.get_vm_by_uuid(vm_ref)
         if not xeninfo:
             return xen_api_error(['HANDLE_INVALID', 'VM', vm_ref])
-        
+
+        domid = xeninfo.getDomid()
+
         record = {
             'uuid': xeninfo.get_uuid(),
             'power_state': xeninfo.get_power_state(),
@@ -1439,6 +1446,7 @@ class XendAPI(object):
             'PCI_bus': xeninfo.get_pci_bus(),
             'tools_version': xeninfo.get_tools_version(),
             'other_config': xeninfo.info.get('other_config', {}),
+            'domid': domid is None and -1 or domid,
             'is_control_domain': xeninfo == xendom.privilegedDomain(),
         }
         return xen_api_success(record)